/**
 * 矩阵转置
 */
function transpose(matrix) {
    for (var i = 0; i < matrix.length(); i = i + 1) {
        for (var j = i; j < matrix.length(); j = j + 1) {
            var t = matrix[i][j]
            matrix[i][j] = matrix[j][i]
            matrix[j][i] = t
        }
    }
}

var mat = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
]
transpose(mat)

for (var i = 0; i < mat.length(); ++i) {
    println(mat[i])
}
